// 移动对话框
export function mousedown(docments: any, option: any, id: any) {
    const doc = docments.target;
    const el: any = document.getElementById(id);
    document.onmousemove = (e: any) => {
        // 计算移动后元素的距离
        const tX = e.movementX + option.left;
        const tY = e.movementY + option.top;
        // 移动当前元素
        if (tX >= 0 && tX <= window.innerWidth - doc.offsetWidth) {
            console.log(isNaN(option.left));
            if (isNaN(option.left)) {
                // option.left = tX;
                el.style.left = `${tX}px`;
            } else {
                // option.right = tX;

                el.style.right = `${tX}px`;
            }
        }
        // 限制移动范围
        if (tY >= 0 && tY <= window.innerHeight - el.offsetHeight) {
            option.top = tY;
        }
    };
}
// 鼠标松开，取消移动事件
export function mouseup() {
    document.onmousemove = null;
    document.onmouseup = null;
}
/**
 * 對話框移動點擊
 */
export const moveMousedown = (docments: any, option: any, id: any) => {
    const doc = docments.target;
    const el: any = document.getElementById(id);
    console.log(el.offsetWidth);
    document.onmousemove = (e: any) => {
        // 计算移动后元素的距离
        const tX = e.movementX + option.left;
        el.style.width = `${el.offsetWidth + tX}px`;
        // // 移动当前元素
        // if (tX >= 0 && tX <= window.innerWidth - doc.offsetWidth) {
        //     option.left = tX;
        // }
    };
};
/**
 * 對話框寬度改變
 */
export const movemouseup = () => {
    console.log("231");
    document.onmousemove = null;
    document.onmouseup = null;
};
